//
//  MyViewControl.m
//  sandbox
//
//  Created by 杨岑 on 3/31/15.
//  Copyright (c) 2015 杨岑. All rights reserved.
//

#import "MyViewControl.h"

@implementation MyViewControl

- (void)drawRect:(NSRect)dirtyRect {
    [[NSColor redColor] set];
    NSFrameRect(self.bounds);
    
    NSFrameRect(NSMakeRect(0, 0, 50, 50));
}

- (void)mouseUp:(NSEvent *)theEvent
{
    NSLog(@"Sending action to target %@", self.target);
    [[NSApplication sharedApplication] sendAction:self.action to:self.target from:self];
    //[self sendAction:self.action to:self.target];
}

- (void)updateTrackingAreas
{
    [super updateTrackingAreas];
    //[self addTrackingRect:self.bounds owner:self userData:nil assumeInside:YES];
}

- (void)mouseEntered:(NSEvent *)theEvent
{
    //NSCursor* cursor = [NSCursor openHandCursor];
    //[cursor set];
}

- (void)mouseExited:(NSEvent *)theEvent
{
    //NSCursor* cursor = [NSCursor arrowCursor];
    //[cursor set];
}

- (void)resetCursorRects
{
    NSCursor* cursor = [NSCursor openHandCursor];
    [self addCursorRect:NSMakeRect(0, 0, 50, 50) cursor:cursor];
    //[cursor setOnMouseEntered:YES];
    //[cursor setOnMouseExited:YES];
}

@end
